package com.kaifamiao.www.demo.Do18;

import java.util.Scanner;

public class Ex06 {
    public static void main(String[] args){
        //输入一个四位数，判断各个位数之和是否大于20


        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个四位数");
        int num = input.nextInt();

        int a = num/1000;

        int b = num%1000/100;

        int c = num/10%10;

        int d = num%10;

        int sum = a + b + c + d;

        System.out.println("千位数:" + a + "百位数:" + b + "十位数；" + c + "个位数："+ d);

        System.out.println("各个位数的和为："+sum);

        if(sum >= 20){
            System.out.println("各位数之和超过20，获得一个奖励");
        }else{
            System.out.println("各位数之没有和超过20，下次见。");
        }



    }
}
